package com.mzpai.product.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mzpai.product.mapper.SystemConfigMapper;
import com.mzpai.product.model.SystemConfig;
import com.mzpai.product.service.SystemConfigService;
import com.mzpai.service.impl.BaseServiceImpl;
/**
 *
 * <b>门店-关键字配置 | Service</b><br>
 *
 * yanglijun 2021-04-08 22:25:22
 * 
 *  @version 1.0.0
 *
 */
@Service
public class SystemConfigServiceImpl extends BaseServiceImpl<SystemConfig> implements SystemConfigService {

	Logger logger = LoggerFactory.getLogger(SystemConfig.class);

	@Autowired 
	private SystemConfigMapper mapper;

	/**
	 *  获取配置
	 * @param storeName
	 * @return
	 */
	@Override
	public SystemConfig getConfigByKey(String keyWord) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("menuName", keyWord);
		List<SystemConfig> list = mapper.getList(map);
		if(list.isEmpty()) {
			return null;
		}
		return list.get(0);
	}

	/**
	 * 多个name 同时查询
	 * @param string
	 * @return
	 */
	@Override
	public Map<String, Object> getConfigMap(String[] nameArr) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("nameArr", nameArr);
		List<SystemConfig> list = mapper.getList(map);
		map.clear();
		for(SystemConfig s : list) {
			map.put(s.getMenuName(), s.getValue().replace("\"", ""));
		}
		return map;
	}
}